package org.codegallery.javagal.jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Savepoint;
import java.sql.Statement;

public class JdbcConnTest {
	public static void main(String[] args){

    }

    public void execute1(Connection conn){
    	
    }

    public void execute2(Connection conn){

    }

    public void executeinner2(Connection conn){
    	Savepoint svpt1=null;
    	try{
    		svpt1 = conn.setSavepoint("SAVEPOINT_1");
    		Statement stmt=conn.createStatement();
    		String sql="";
    		stmt.execute(sql);
    	}catch(Exception ex){
    		ex.printStackTrace();
    		if(svpt1!=null){
    			try{
    				conn.rollback(svpt1);
    			}catch(Exception ex1){
    				ex1.printStackTrace();
    			}
    			
    		}
    		
    	}
    	
    }

    /** sql server driver class name"net.sourceforge.jtds.jdbc.Driver"
     * 
     * @param className
     * @param url
     * @param userName
     * @param password
     * @return
     */
    //
    private Connection getConnection(String className,String url, String userName,
			String password) {
		try {
			Class.forName(className);
			Connection con = DriverManager.getConnection(url, userName, password);
			if (con != null) {
				System.out.println("Connection Successful!!");
			}
            return con;
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("Error Trace in getConnection() : "
					+ e.getMessage());
		}
		return null;
	}
}
